/**
 * JAVACC DEMO 1.0
 * @copy right dwusoft company All rights reserved. 
 */
package com.apache.order.entity;

import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.List;


/**
 * description:  订单vo
 * @author Hou Dayu 创建时间：2015-8-5  
 */
@SuppressWarnings("serial")
public class OrderMainVo extends TOrder {

	private List<TOrderDetail> porducts;

	public List<TOrderDetail> getPorducts() {
		return porducts;
	}

	public void setPorducts(List<TOrderDetail> porducts) {
		this.porducts = porducts;
	}

	/* 
	   * 将父类所有的属性COPY到子类中。 
	   * 类定义中child一定要extends father； 
	   * 而且child和father一定为严格javabean写法，属性为deleteDate，方法为getDeleteDate 
	   */
	public void fatherToChild(TOrder father, OrderMainVo child) {
		Field ff[] = father.getClass().getDeclaredFields();
		try {
			for (Field field : ff) {
				field.setAccessible(true);
				Method m = father.getClass().getMethod("get" + upperHeadChar(field.getName()));//方法getDeleteDate  
				Object obj = m.invoke(father);//取出属性值              
				field.set(child, obj);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	/** 
	* 首字母大写，in:deleteDate，out:DeleteDate 
	*/
	private String upperHeadChar(String in) {
		String head = in.substring(0, 1);
		String out = head.toUpperCase() + in.substring(1, in.length());
		return out;
	}
}
